package com.sgb.kjwl.view.ui.adapter.personmanger;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.PersonInfoEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class PersonMangerAdapter extends BaseRecycleAdapter<PersonInfoEntity> {

    private TextView textView;
    private Idelete idelete;
    public PersonMangerAdapter(Context context, List<PersonInfoEntity> datas) {
        super(context, R.layout.item_person_manger, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, PersonInfoEntity powerEntity) {
        holder.setBinding(BR.viewModel, powerEntity);
        textView = holder.itemView.findViewById(R.id.delete_tv);
        textView.setOnClickListener(view -> {
            idelete.onDelete(powerEntity.getId(),holder.getAdapterPosition());
        });
    }

    public interface Idelete{
        void onDelete(String id,int position);
    }

    public void Idelete(Idelete idelete){
        this.idelete = idelete;
    }
}
